﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NoteBox
{
    public partial class Time : Form
    {
        int id;

        public event dTime TimeSet;

        public Time(int _id,DateTime date, int hour, int minute)
        {
            InitializeComponent();
            //
            id = _id;
            //
            if (hour == -1)
                numericUpDown1.Value = (decimal)DateTime.Now.Hour;
            else
                numericUpDown1.Value = (decimal)hour;
            if (minute == -1)
                numericUpDown2.Value = (decimal)DateTime.Now.Minute;
            else
                numericUpDown2.Value = minute;
            if (date == DateTime.Parse("01.01.1001"))
                monthCalendar1.SelectionStart = DateTime.Now;
            else
                monthCalendar1.SelectionStart = date;
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            TimeSet(id, monthCalendar1.SelectionStart.Date, (int)numericUpDown1.Value, (int)numericUpDown2.Value);
            this.Dispose();
        }
        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }
        private void buttonDel_Click(object sender, EventArgs e)
        {   // заглушками заменяем...
            TimeSet(id, DateTime.Parse("01.01.1001"), -1, -1);
            this.Dispose();
        }

        private void Settings_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.Dispose();
        }
        
    }
}
